﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.sprite.changeSourceSize;
using imaginecup.util;
using Imaginecup.sprite;
using Microsoft.Xna.Framework;
using Imaginecup.util;
using Imaginecup.util.collision;
using Microsoft.Xna.Framework.Input;
using Imaginecup.gameState.btnStateUtil;

namespace Imaginecup.gameState.temp
{
    public class DrawBtnInfo:ISourceInfoClass
    {
        private bool m_Enable;
        private BtnInfo m_BtnInfo;
        private EntityInfo m_BtnEntityInfo;

        private EntityInfo m_SourceInfo;

        public DrawBtnInfo()
        {
            m_Enable = true;
        }
        public void SetBtnInfo(BtnInfo info)
        {
            m_BtnInfo = info;
            m_BtnEntityInfo = m_BtnInfo.GetEntityInfo();
            m_Enable = info.GetEnable();

            m_SourceInfo = new EntityInfo(new Vector2(3 * m_BtnEntityInfo.mSize.X, 0), m_BtnEntityInfo.mSize);
        }


        public void Update()
        {
            if (m_Enable == false)
            {
                m_SourceInfo = new EntityInfo(new Vector2(3 * m_BtnEntityInfo.mSize.X, 0), m_BtnEntityInfo.mSize);
                return;
            }

            IMouseInputHandler input = MouseInputHandler.GetInputHandler();

            if (Collision.CollisionByPoint(m_BtnEntityInfo, input.Position) && input.MouseState.LeftButton == ButtonState.Pressed)
            {
                m_SourceInfo = new EntityInfo(new Vector2(m_BtnEntityInfo.mSize.X, 0), m_BtnEntityInfo.mSize);
                return;
            }
#if WINDOWS
            else if (Collision.CollisionByPoint(m_BtnEntityInfo, input.Position))
            {
                m_SourceInfo = new EntityInfo(new Vector2(m_BtnEntityInfo.mSize.X * 2, 0), m_BtnEntityInfo.mSize);
                return;
            }
#endif

            m_SourceInfo = new EntityInfo(Vector2.Zero, m_BtnEntityInfo.mSize);
        }

        public EntityInfo GetSourceInfo()
        {
            return m_SourceInfo;
        }

    }
}
